home *** CD-ROM | disk | FTP | other *** search
- (*----------------------------------------------------------------------*)
- (* InitTerm --- Initialize PibTerm *)
- (*----------------------------------------------------------------------*)
-
- OVERLAY PROCEDURE InitTerm;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: InitTerm *)
- (* *)
- (* Purpose: Initializes PibTerm *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* InitTerm; *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Done_Flag : BOOLEAN;
- F : TEXT;
- Ch : CHAR;
-
- (*----------------------------------------------------------------------*)
- (* Modem_Connected --- Check if modem connected *)
- (*----------------------------------------------------------------------*)
-
- FUNCTION Modem_Connected : BOOLEAN;
-
- VAR
- Start_Time: REAL;
- Timed_Out : BOOLEAN;
-
- BEGIN (* Modem_Connected *)
- (* Turn on OUT2, DTR, and RTS *)
-
- Port[UART_MCR + Async_Base] := $0B;
-
- (* Wait for DSR using Busy Wait *)
- Start_Time := TimeOfDay;
- Timed_Out := FALSE;
-
- IF Async_Do_DSR THEN
- WHILE ( NOT Timed_Out ) AND
- ( ( Port[UART_MSR + Async_Base] AND $20 ) = 0 ) DO
- Timed_Out := ( TimeDiff( Start_Time , TimeOfDay ) > 2.0 );
-
- (* Wait for CTS using Busy Wait *)
- Start_Time := TimeOfDay;
-
- IF Async_Do_CTS THEN
- WHILE ( NOT Timed_Out ) AND
- ( ( Port[UART_MSR + Async_Base] AND $10 ) = 0 ) DO
- Timed_Out := ( TimeDiff( Start_Time , TimeOfDay ) > 2.0 );
-
- (* Wait for Transmit Hold Register Empty (THRE) *)
- Start_Time := TimeOfDay;
-
- WHILE ( NOT Timed_Out ) AND
- ( ( Port[UART_LSR + Async_Base] AND $20 ) = 0 ) DO
- Timed_Out := ( TimeDiff( Start_Time , TimeOfDay ) > 2.0 );
-
- (* If we looped through, modem probably *)
- (* not connected. *)
-
- Modem_Connected := ( NOT Timed_Out );
-
- END (* Modem_Connected *);
-
- (*----------------------------------------------------------------------*)
-
- BEGIN (* InitTerm *)
- (* Get session start time *)
-
- Session_Start_Time := TimeOfDay;
- Dialing_Start_Time := Session_Start_Time;
-
- (* Initialize critical error *)
- (* handler routine. *)
- Int24ON;
- (* Initialize handler for *)
- (* other errors. *)
-
- ErrorPtr := OFS( Error_Handler );
-
- (* Clear screen *)
- ClrScr;
- (* Select color/mono screen *)
-
- Get_Screen_Address( Actual_Screen );
-
- (* Assume text mode from *)
- (* current system setting. *)
- CASE Current_Video_Mode OF
-
- 0, 2, 7 : Text_Mode := BW80;
- 1, 3, 4, 5, 6 : Text_Mode := C80;
-
- END (* CASE *);
-
- TextMode( Text_Mode );
- (* Set colors as black and white *)
-
- Set_Global_Colors( White, Black );
-
- ForeGround_Color := White;
- BackGround_Color := Black;
- Menu_Text_Color := White;
- Menu_Frame_Color := White;
- (* Set VT100 colors *)
-
- VT100_ForeGround_Color := LightGray;
- VT100_BackGround_Color := Black;
- VT100_Underline_Color := Blue;
- VT100_Bold_Color := White;
-
- (* Set saved screen pointer *)
- Saved_Screen := NIL;
- (* Silent mode OFF to start *)
- Silent_Mode := FALSE;
- (* Local echo starts at OFF *)
- Local_Echo := FALSE;
- (* Gossip mode starts at OFF *)
- Gossip_Mode_On := FALSE;
- (* Host Mode starts at OFF *)
- Host_Mode := FALSE;
- (* Phone number to dial *)
- Phone_Number := '';
- (* Last column not hit yet *)
- Last_Column_Hit := FALSE;
- (* Wrap long lines *)
- Auto_Wrap_Mode := TRUE;
- (* No blinking in effect *)
- Blinking_On := 0;
- (* No script file being used *)
- Script_File_Mode := FALSE;
- (* Set empty review buffer *)
- Review_Head := 0;
- Review_Tail := 0;
- Review_Line := '';
- Review_Buffer := NIL;
- (* No WHEN string in use *)
- Script_When_Text := '';
- Script_When_Reply_Text := '';
- Script_When_Save := '';
- When_Mode := FALSE;
- (* No WAITSTRING in use *)
- Script_Wait_Text := '';
- Script_Wait_Reply_Text := '';
- Script_Wait_Save := '';
- Script_Wait_Found := FALSE;
- WaitString_Mode := FALSE;
- Read_In_Script := FALSE;
- Really_Wait_String := FALSE;
- Script_Suspend_Time := 0.0;
- (* No script to start *)
- Script_Buffer := NIL;
- Script_Buffer_Size := 0;
-
- (* Carrier not set high by default *)
- Modem_Carrier_High := FALSE;
-
- (* Establish Communications *)
-
- IF NOT Set_Params( TRUE , FALSE ) THEN
- BEGIN
- WRITELN('*** Sorry, can''t initialize communications.');
- WRITELN('*** Program stops.');
- Halt;
- END;
- (* Give Program Notice *)
-
- WRITELN('PibTerm Version ', PibTerm_Version,' Ready.');
- WRITELN('Hit Alt-I for command list.');
-
- (* Initialize Modem *)
-
- IF NOT Modem_Connected THEN
- BEGIN
- WRITELN('*** Modem appears to be turned off.');
- WRITELN('*** Please turn it on and then hit any key to continue.');
- READ( Kbd, Ch );
- IF ( Ch = CHR( ESC ) ) AND KeyPressed THEN
- READ( Kbd, Ch );
- END;
-
- IF Modem_Init <> '' THEN
- BEGIN
- WRITELN('Modem initialization: ',Write_Ctrls( Modem_Init ) );
- Send_Modem_Command( Modem_Init );
- Async_Purge_Buffer;
- END;
- (* Pick up script file name if any, *)
- (* and convert to executable form. *)
- IF ParamCount > 0 THEN
- BEGIN
- Script_File_Name := ParamStr( 1 );
- Process_Script;
- END
- ELSE (* Check if PIBTERM.SCR exists. *)
- BEGIN
- ASSIGN( F , 'PIBTERM.SCR' );
- (*$I-*)
- RESET( F );
- (*$I+*)
- IF ( Int24Result = 0 ) THEN
- BEGIN
- CLOSE( F );
- Script_File_Name := 'PIBTERM.SCR';
- Process_Script;
- END;
- END;
-
- END (* InitTerm *);